﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WisDom.IService;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace WisDom.Update.Controllers
{
    /// <summary>
    /// 客户文件
    /// </summary>
    [Route("api/[controller]")]
    public class ClientFileController : Controller
    {
        IBackupClientFileInterface backupClientFileService;
        public ClientFileController(IBackupClientFileInterface backupClientFileService)
        {
            this.backupClientFileService = backupClientFileService;
        }
        /// <summary>
        /// 获取下载文件路径
        /// </summary>
        /// <returns></returns>
        [HttpGet("{id}",Name = "GetDownloadFilePath")]
        public async Task<IActionResult> GetDownloadFilePath(int id)
        {
            string filePath = "";
            var entity = await backupClientFileService.GetEntity(id.ToString());
            if (entity != null)
            {
                filePath = entity.FilePath;
            }
            return new JsonResult(new { status = string.IsNullOrEmpty(filePath) ? false : true, webFilePath = filePath });
        }

    }
}
